package com.mydemo.design_pattern.create_type.single_pattern;

import java.io.*;

/**
 * <p></p >
 *
 * @author liming1
 * @version $Id: DemoTest, v1.0 2019-09-18 14:33 liming1 Exp $
 */
public class DemoTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        SingleObj1 obj1 = SingleObj1.getSingleObj();
        SingleObj1 obj2 = SingleObj1.getSingleObj();
        System.out.println(obj1 == obj2);


        SingleObj2 obj3 = SingleObj2.getSingleObj();
        ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream("bb.txt"));
        outputStream.writeObject(obj3);

        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("bb.txt"));
        SingleObj2 o = (SingleObj2) objectInputStream.readObject();
        System.out.println(obj3 == o);
    }
}
